Imports Lucene.Net.Search
Imports Aricie.DNN.UI.WebControls

Namespace Aricie.DNN.Modules.LuceneSearch.UI.Controls
    Public Class OccurSelector
        Inherits SelectorControl(Of Occur)

        Private Shared _Occurs As List(Of Occur)


        Public Overrides Function GetEntitiesG() As IList(Of Occur)
            If _Occurs Is Nothing Then
                _Occurs = New List(Of Occur)
                _Occurs.Add(Occur.MUST)
                _Occurs.Add(Occur.MUST_NOT)
                _Occurs.Add(Occur.SHOULD)
            End If
            Return _Occurs
        End Function


        Public Overrides Sub DataBind()
            Dim currentOccur As Occur = Me.SelectedObjectG
            Me.Items.Clear()
            If Me.DataSource Is Nothing Then
                Me.DataSource = Me.AllItems
            End If
            Dim item As ListItem
            For Each objOccur As Occur In DirectCast(Me.DataSource, IList(Of Occur))
                item = New ListItem(objOccur.ToString(), objOccur.ToString())
                If currentOccur <> Nothing AndAlso objOccur.Equals(currentOccur) Then
                    item.Selected = True
                End If
                Me.Items.Add(item)
            Next
            If Me.LocalizeItems Then
                Me.DoLocalizeItems()
            End If
        End Sub


        Protected Overrides ReadOnly Property UnifyInstances() As Boolean
            Get
                Return False
            End Get
        End Property
    End Class
End Namespace
